import java.util.Scanner;
import java.util.Random;
public class Doors {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		String in;
		int sel;
		int tot=0;
		Random rand=new Random();
		String[] clud=new String[20]; //Included numbers
		Scanner input=new Scanner(System.in);
		System.out.println("What color would you like to see if is in the array");
		in=input.next();
		for (int i=0;i<20;i++){
			sel=rand.nextInt(7);
			clud[i]=select(sel);
		}
		for (int i=0;i<20;i++){
			if (clud[i].equalsIgnoreCase(in)){
				tot=tot+1;
			}
		}
		if (tot==1){
			System.out.println("The color was in the array "+tot+" time.");
			String ans;
			System.out.println("Would you like to run again?");
			ans=input.next();
			if (ans.equalsIgnoreCase("yes")){
				main(args);
			}
			else{
				System.out.println("Goodbye!");
			}
		}
		else if(tot==0){
			System.out.println("The color wasn't in the array.");
			String ans;
			System.out.println("Would you like to run again?");
			ans=input.next();
			if (ans.equalsIgnoreCase("yes")){
				main(args);
			}
			else{
				System.out.println("Goodbye!");
			}
		}
		else{
			System.out.println("The color was in the array "+tot+" times.");
			String ans;
			System.out.println("Would you like to run again?");
			ans=input.next();
			if (ans.equalsIgnoreCase("yes")){
				main(args);
			}
			else{
				System.out.println("Goodbye!");
			}
		}
		String ans;
		System.out.println("Would you like to run again?");
		ans=input.next();
		if (ans.equalsIgnoreCase("yes")){
			main(args);
		}
		else{
			System.out.println("Goodbye!");
		}

	}
	static String select(int random){
		if (random==0){
			return "red";
		}
		else if (random==1){
			return "orange";
		}
		else if (random==2){
			return "yellow";
		}
		else if (random==3){
			return "green";
		}
		else if (random==4){
			return "blue";
		}
		else if (random==5){
			return "indigo";
		}
		else if (random==6){
			return "violet";
		}
		else{
			return "white";
		}
	}
	}
